package happy.diandiankong.api.db;

import happy.diandiankong.api.model.Users;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;

/**
 * Title.
 * <p>
 * Description.
 *
 * @author Bill Lv {@literal <billcc.lv@hotmail.com>}
 * @version 1.0
 * @since 2016-10-30
 */
public interface UserDao extends AutoCloseable, Transactional<UserDao> {
    @SqlUpdate("INSERT INTO DDK_USERS (ID, NAME, GROUP_ID) VALUES (:ID, :NAME, :GROUP_ID)")
    void insert(@Bind("ID") Long id, @Bind("NAME") String name, @Bind("GROUP_ID") Long groupId);

    @SqlQuery("SELECT ID, NAME, GROUP_ID FROM DDK_USERS WHERE ID = :ID")
    @Mapper(UserMapper.class)
    Users findById(@Bind("ID") Long id);
}
